# By Daoyu @2010-07-07
from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.template import RequestContext

from uncle.users.models import *

def show_403(request):
    msg = ''
    if request.GET.has_key('msg'):
        msg = request.GET['msg']
    
    return render_to_response('403.html',
        {'msg':msg,},         
        context_instance=RequestContext(request))

#-------------------------------------------------------------------------------
# Show the passwords of all users, if they've changed their passwords.
#-------------------------------------------------------------------------------
@login_required
def show_pwd(request):
    if not request.user.username == 'kth':
        return HttpResponseRedirect('/403/?msg=You do not have the permission to view this page');
    pwds = Pwd.objects.all()
    
    return render_to_response('user/pwd.html',
    {'pwds':pwds},
    context_instance=RequestContext(request)) 

#-------------------------------------------------------------------------------
# Display the http://.../other/ page.
#-------------------------------------------------------------------------------
@login_required
def other(request):
    return render_to_response('other.html',
        {},         
        context_instance=RequestContext(request)) 

#-------------------------------------------------------------------------------
# Display the about page.
#-------------------------------------------------------------------------------
def about(request):
    return render_to_response('about.html',
        {},         
        context_instance=RequestContext(request))

#-------------------------------------------------------------------------------
# Init the category.
#-------------------------------------------------------------------------------
@login_required
def init_category(request):
    Category.objects.all().delete()
    cats = ['Producer','HighSpeed / Phantom','Director','Dop', 'Editor','Colorist', 'Motion Grapher','Illustrator',\
            'Web','Programmer','3D','2D','Moods','Companies']
    skills = [['Agency experienced','Filmproduction experienced','Postproduction experienced',\
              'On set supervision','Post Supervision','Feature','Commerical','Music videos','Procter & Gamble cost calc',\
              'Editing'],\
              ['Tabletop / Macro','Storytelling','Lifestyle','Green Screen','Stereoscopic','Motion Control',\
               'Heli Shooting','Steady Cam','Remote Helicopter'],\
              ['Art Direction','Creative Direction','Copy Feature','Commercial','Conception',\
               'Supervision','Stereoscopic'],\
              ['Action','Beauty','Car','Food','Liquids','Tabletop/Macro','Storytelling','Lifestyle','Green screen','Stereoscopic',\
              'Motion Control','Heli Shooting','Steady CaM','REMOTE Hlicopter'],\
              ['Feature','Commercial','Music','Coorporate','Beauty','Car','Action','Story Telling','FX Editing','Stereoscopic'],\
              ['Feature','Commercial','Music Video','Coorporate','Stereoscopic','Beauty','Car'],\
              ['Logo Design','Broadcast Design','Coorprate Design','Particle systems/Particular','2D/3D Integration','Layout/Conception','Web',\
               'Stereoscopic','Styleframe development','Storyboard'],\
              ['Storyboard','Scribbles','Visuals','Animation','Key Posing','Icons','Pictorgram',\
               'Editorial','Mood Boards','Acryl','Aquarell','Black & White','Line','Pencil','Childrens-book',\
               'Cartoon','Digital','Fine Liner','Plasticine','Chalk','PhotoRealistic','OEL','India Ink',
               'Vector','Phantasy'],\
              ['Web design','Content Management system','Template development','SEO','Webblog'],\
              ['Scripting','2D Workflow','3D Workflow'],\
              ['Supervisor','Generalist','Tracking','Shading','Fluid','DMP','Modelling',\
               'Character / Creature TD','Fur','Animation','Rigging','Particles',\
               'Lighting ID','Crowds','Environment ID','Digi Doubles','Car'],\
               ['Compositing','Paint/Roto','Concept Art','Matte Painter','Beauty'],\
               ['Feature','Commercial','Music Video','Cooperate','Beauty','Car','Motion Graphic',\
                'Shorts','Making of','Interactive','Web 2.0','Flash MOP','Viral','Animations',\
                'Web film','Fashion','High speed','TYPO','FOOD','Table Top','Documentation',\
                'Social','Promo','Real & Animation','Footage','Sports','Stop Motion',\
                'Artist Projects','Kids','Stereoscopic'],\
               ['Post house','Design studio','3d Specialists','Web Designers']]
    tools = [['Avid','Final Cut Pro','Farmers Wife'],\
             [],\
             ['Photoshop','In Design','Freehand','QuarkXPress','Flash','Cinema 4D',\
              'Maya-Texturing','Illustrator'],\
             ['Arri/Film','Arri/Alexa','Red','D5/D7','Digital Highspeed/Phantom'],\
             ['Final Cut','Avid'],\
             ['Baselight','Lustre','Pogle','Film Master','Da Vinci 2K','Resolve','Cintel',\
              'Spirit','Color','Scratch','Speed Grade','Mystika'],\
             ['Cinema 4D','After effects','PhotoShop','Illustrator','Integration','Shake','Flash'],\
             ['Painter','Photoshop','Illustrator','Freehand','QuarkXPress','In design','Flash',\
              'Bodypaint - Cinema 4D','Maya-Texturing'],\
             ['Flash','HTML 5','CMS','Web 2.0','Micropage','Information side','HTML','CSS','PHP',\
              'DATABASE','PAPERVISION'],\
             ['Python','C++','OFX','NUKE SDK','Open GL','GPU','Flash'],\
             ['Bojou','Maya','MAX','XSI','Zbrush','Renderman','Mental Ray','MEL','Houdini','Massive',\
              'Syflex','NCloth','Python','C++','Krakatoa','Mudbox','Blender','Cinema 4D'],\
              ['Nuke','Flame','Smoke','Fusion','After Effects','Shake','Combustion','Silhouette',\
               'Body Paint','Deep Paint','Photoshop','Mokey'],\
               [],\
               []]
    
    for i in range(0,len(cats)):
        obj = Category()
        obj.name = cats[i]
        obj.save()
        
        for x in skills[i]:
            skl = Skill()
            skl.name = x
            skl.category = obj
            skl.save()
        
        for x in tools[i]:
            tl = Tool()
            tl.name = x
            tl.category = obj
            tl.save()
    
    return HttpResponseRedirect('/user/category/')
